﻿/**
//  CameraModel.cs
//  Marquee Moment
//  Copyright 2011 Systematix Technocrates. All rights reserved.
**/
using System;
using EDSDKLib;

namespace MarqueeMoment.CameraController.Camera
{
    public class CameraModel : Observable
    {



        protected IntPtr camera;
        //// UIlock counter

        protected int lockCount;
        //// Model name

        protected string modelName;
        //// Parameters
        protected int AEMode;
        protected int Av;
        protected int Tv;
        protected int Iso;
        protected int MeteringMode;
        protected int ExposureCompensation;
        protected int ImageQuality;

        protected int availableShot;
        //// Available parameter lists
        protected EDSDK.EdsPropertyDesc AEModeDesc;
        protected EDSDK.EdsPropertyDesc AvDesc;
        protected EDSDK.EdsPropertyDesc TvDesc;
        protected EDSDK.EdsPropertyDesc IsoDesc;
        protected EDSDK.EdsPropertyDesc MeteringModeDesc;
        protected EDSDK.EdsPropertyDesc ExposureCompensationDesc;

        protected EDSDK.EdsPropertyDesc ImageQualityDesc;

        //// Constructor
        public CameraModel(IntPtr camera)
        {
            this.lockCount = 0;
            this.camera = camera;
        }

        //// Get a camera object
        public IntPtr getCameraObject()
        {
            return this.camera;
        }


        //// -----------------------------------------------------------------
        //// Stock parameters ---------------------------------------------

        private void setAEMode(int value)
        {
            AEMode = value;
        }

        private void setTv(int value)
        {
            Tv = value;
        }

        private void setAv(int value)
        {
            Av = value;
        }

        private void setIso(int value)
        {
            Iso = value;
        }

        private void setMeteringMode(int value)
        {
            MeteringMode = value;
        }

        private void setExposureCompensation(int value)
        {
            ExposureCompensation = value;
        }

        private void setImageQuality(int value)
        {
            ImageQuality = value;
        }

        private void setModelName(string modelName)
        {
            //modelName = modelName; 23 December_2011
        }

        //// -----------------------------------------------------------------
        //// Give parameters ---------------------------------------------

        private int getAEMode()
        {
            return AEMode;
        }

        private int getTv()
        {
            return Tv;
        }

        private int getAv()
        {
            return Av;
        }

        private int getIso()
        {
            return Iso;
        }

        private int getMeteringMode()
        {
            return MeteringMode;
        }

        private int getExposureCompensation()
        {
            return ExposureCompensation;
        }

        private int getImageQuality()
        {
            return ImageQuality;
        }

        //// -----------------------------------------------------------------
        //// Give available parameter lists ----------------------------------

        private EDSDK.EdsPropertyDesc getAEModeDesc()
        {
            return AEModeDesc;
        }

        private EDSDK.EdsPropertyDesc getAvDesc()
        {
            return AvDesc;
        }

        private EDSDK.EdsPropertyDesc getTvDesc()
        {
            return TvDesc;
        }

        private EDSDK.EdsPropertyDesc getIsoDesc()
        {
            return IsoDesc;
        }

        private EDSDK.EdsPropertyDesc getMeteringModeDesc()
        {
            return MeteringModeDesc;
        }

        private EDSDK.EdsPropertyDesc getExposureCompensationDesc()
        {
            return ExposureCompensationDesc;
        }

        private EDSDK.EdsPropertyDesc getImageQualityDesc()
        {
            return ImageQualityDesc;
        }


        //// -----------------------------------------------------------------
        //// Stock available parameter lists ---------------------------------

        private void setAEModeDesc(EDSDK.EdsPropertyDesc desc)
        {
            AEModeDesc = desc;
        }

        private void setAvDesc(EDSDK.EdsPropertyDesc desc)
        {
            AvDesc = desc;
        }

        private void setTvDesc(EDSDK.EdsPropertyDesc desc)
        {
            TvDesc = desc;
        }

        private void setIsoDesc(EDSDK.EdsPropertyDesc desc)
        {
            IsoDesc = desc;
        }

        private void setMeteringModeDesc(EDSDK.EdsPropertyDesc desc)
        {
            MeteringModeDesc = desc;
        }

        private void setExposureCompensationDesc(EDSDK.EdsPropertyDesc desc)
        {
            ExposureCompensationDesc = desc;
        }

        private void setImageQualityDesc(EDSDK.EdsPropertyDesc desc)
        {
            ImageQualityDesc = desc;
        }


        //// Set a property <UInt32>
        public void setPropertyUInt32(uint propertyID, int value)
        {
            switch (propertyID)
            {
                case EDSDK.PropID_AEMode:
                    setAEMode(value);
                    break;
                case EDSDK.PropID_Tv:
                    setTv(value);
                    break;
                case EDSDK.PropID_Av:
                    setAv(value);
                    break;
                case EDSDK.PropID_ISOSpeed:
                    setIso(value);
                    break;
                case EDSDK.PropID_MeteringMode:
                    setMeteringMode(value);
                    break;
                case EDSDK.PropID_ExposureCompensation:
                    setExposureCompensation(value);
                    break;
                case EDSDK.PropID_ImageQuality:
                    setImageQuality(value);
                    break;
            }
        }


        //// Get a property <UInt32>
        public uint getPropertyUInt32(uint propertyID)
        {
            uint value = 0xffffffff;
            switch (propertyID)
            {
                case EDSDK.PropID_AEMode:
                    value = (uint)getAEMode();
                    break;
                case EDSDK.PropID_Tv:
                    value = (uint)getTv();
                    break;
                case EDSDK.PropID_Av:
                    value = (uint)getAv();
                    break;
                case EDSDK.PropID_ISOSpeed:
                    value = (uint)getIso();
                    break;
                case EDSDK.PropID_MeteringMode:
                    value = (uint)getMeteringMode();
                    break;
                case EDSDK.PropID_ExposureCompensation:
                    value = (uint)getExposureCompensation();
                    break;
                case EDSDK.PropID_ImageQuality:
                    value = (uint)getImageQuality();
                    break;
            }
            return value;

        }


        //// Get a property <String>
        public void getPropertyString(uint propertyID, ref string str)
        {
            switch (propertyID)
            {
                case EDSDK.PropID_ProductName:
                    str = modelName;
                    break;
            }
        }


        //// Set a property <String>
        public void setPropertyString(uint propertyID, string str)
        {
            switch (propertyID)
            {
                case EDSDK.PropID_ProductName:
                    modelName = str;
                    break;
            }
        }


        //// Set an available parameter list.
        public void setPropertyDesc(uint propertyID, EDSDK.EdsPropertyDesc desc)
        {
            switch (propertyID)
            {
                case EDSDK.PropID_AEMode:
                    setAEModeDesc(desc);
                    break;
                case EDSDK.PropID_Tv:
                    setTvDesc(desc);
                    break;
                case EDSDK.PropID_Av:
                    setAvDesc(desc);
                    break;
                case EDSDK.PropID_ISOSpeed:
                    setIsoDesc(desc);
                    break;
                case EDSDK.PropID_MeteringMode:
                    setMeteringModeDesc(desc);
                    break;
                case EDSDK.PropID_ExposureCompensation:
                    setExposureCompensationDesc(desc);
                    break;
                case EDSDK.PropID_ImageQuality:
                    setImageQualityDesc(desc);
                    break;
            }
        }

        //// Get an available parameter list.
        public EDSDK.EdsPropertyDesc getPropertyDesc(uint propertyID)
        {
            EDSDK.EdsPropertyDesc desc=new EDSDK.EdsPropertyDesc();//EDSDK.EdsPropertyDesc desc = null; 23 December_2011
            switch (propertyID)
            {
                case EDSDK.PropID_AEMode:
                    desc = getAEModeDesc();
                    break;
                case EDSDK.PropID_Tv:
                    desc = getTvDesc();
                    break;
                case EDSDK.PropID_Av:
                    desc = getAvDesc();
                    break;
                case EDSDK.PropID_ISOSpeed:
                    desc = getIsoDesc();
                    break;
                case EDSDK.PropID_MeteringMode:
                    desc = getMeteringModeDesc();
                    break;
                case EDSDK.PropID_ExposureCompensation:
                    desc = getExposureCompensationDesc();
                    break;
                case EDSDK.PropID_ImageQuality:
                    desc = getImageQualityDesc();
                    break;
            }
            return desc;
        }

        //// Check camera accessing flag.
        //// Connected camera is not a legacy one, this method will be called.
        public virtual bool isLegacy()
        {
            return false;
        }

    }
}
